package cn.song.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class AdminLoginInterceptor implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> list=new ArrayList<>();
        list.add("/Admin/Login");
        list.add("/Admin/adminLogin");
        list.add("/Admin/Dis/saveFenXiaoShang");

        list.add("/**/page/*.html");
        list.add("/**/*.js");
        list.add("/**/*.css");
        list.add("/**/*.json");
        list.add("/**/*.jpg");
        list.add("/**/*.png");
        list.add("/**/*.ico");
        list.add("/**/*.xlsx");
        list.add("/**/*.xls");
        list.add("/**/*.cvs");
        list.add("/**/*.woff");
        list.add("/**/*.ttf");
        List<String> list1=new ArrayList<>();
        InterceptorRegistration registration = registry.addInterceptor(admin());
        registration.addPathPatterns("/Admin/**");    //所有路径都被拦截
        registration.excludePathPatterns(list);
    }



    @Bean
    public MyAdminInterpcter admin(){
        return new MyAdminInterpcter();
    }

}
